import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { getDictTypeListApi } from '/@/api/admin/dict';
import { DICT } from '/@/enums/dict';

export const columns: BasicColumn[] = [
  {
    title: '编码',
    dataIndex: 'connCode',
    // align: 'left',
  },
  {
    title: '名称',
    dataIndex: 'connName',
  },
  {
    title: '服务器名称',
    dataIndex: 'serverName',
  },
  {
    title: '数据库名称',
    dataIndex: 'dbName',
  },
  {
    title: '数据库类型',
    dataIndex: 'dbTypeName',
  },
  {
    title: '连接方式',
    dataIndex: 'connTypeName',
  },
  {
    title: '用户名',
    dataIndex: 'userCode',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'connName',
    label: '名称',
    component: 'Input',
    colProps: { span: 6 },
  },

  {
    field: 'dbName',
    label: '数据库名称',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'userCode',
    label: '用户名',
    component: 'Input',
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'connCode',
    label: '编码',
    component: 'Input',
    required: true,
  },
  {
    field: 'connName',
    label: '名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'serverName',
    label: '服务器名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'dbName',
    label: '数据库名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'dbType',
    label: '数据库类型',
    component: 'ApiSelect',
    required: true,
    componentProps: {
      api: getDictTypeListApi,
      labelField: 'label',
      valueField: 'intValue',
      params: {
        type: DICT.DB_TYPE,
      },
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'connType',
    label: '连接方式',
    component: 'ApiSelect',
    required: true,
    componentProps: {
      api: getDictTypeListApi,
      labelField: 'label',
      valueField: 'intValue',
      params: {
        type: DICT.CNN_TYPE,
      },
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'userCode',
    label: '用户名',
    component: 'Input',
    required: true,
  },
  {
    field: 'password',
    label: '密码',
    required: true,
    component: 'InputPassword',
  },
  {
    field: 'accessNo',
    label: '端口号',
    required: true,
    component: 'InputNumber',
  },
  {
    field: 'pwdType',
    label: '加密方式',
    component: 'InputNumber',
  },
];
